/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2021-2022. All rights reserved.
 *
 */

import { Project } from '@ohos/hvigor';

import { CoreProjectModelImpl } from '../model/project/core-project-model-impl.js';
import { ProjectModelImpl } from '../model/project/project-model-impl.js';
import { DependencyManager } from '../project/dependency/dependency-manager.js';
import { ProjectTaskService } from '../tasks/service/project-task-service.js';

import { AbstractProjectPlugin } from './common/abstract-project-plugin.js';

/**
 * 对外暴露app级别的接口和任务的plugin
 *
 * @since 2021/12/16
 */
export class AppPlugin extends AbstractProjectPlugin {
  constructor(project: Project) {
    super(project);
    const projectModel = new ProjectModelImpl(project) as CoreProjectModelImpl;
    projectModel.initSubProject();
    this._projectModel = projectModel;
  }

  initTaskService(): void {
    const dependencyManager = new DependencyManager(false, this._projectModel!);
    this._taskService = new ProjectTaskService(this._project, this._projectModel!, dependencyManager, false);
  }
}
